package com.hzlx.controller;/*
 *@author liu
 *2024/07/2024/7/25
 *@version
 */

import com.hzlx.common.ResponseBean;
import com.hzlx.entity.WatchList;
import com.hzlx.service.AccountFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @Author UP
 * @Date 2024/7/25 9:04
 * @Version 1.0
 **/
@Controller
@RequestMapping("/account")
public class AccountFlowController {

    @Autowired
    private AccountFlowService accountFlowService;

    @RequestMapping("/getList")
    @ResponseBody
    public ResponseBean getList(Integer pageIndex, Integer pageSize) {
        return accountFlowService.getAll(pageIndex, pageSize);
    }

    @GetMapping("/edit/{id}")
    public String goEdit(@PathVariable("id")Integer id, String op, HttpSession session){
        ResponseBean responseBean = accountFlowService.getById(id,op,session);
        return "pages/audit";
    }
    @PostMapping("/updateWatch")
    @ResponseBody
    public ResponseBean updateWatch(Integer id, BigDecimal amount, Date createTime, Date successTime,
                                    String userName, String telNumber, String bankName, String cardType,
                                    String cardNo, Integer status, String flowNo, String refuse, String voucher){
        WatchList watchList = new WatchList();
        watchList.setId(id);
        watchList.setFlowNo(flowNo);
        watchList.setAmount(amount);
        watchList.setCreateTime(createTime);
        watchList.setSuccessTime(null);
        watchList.setUserName(userName);
        watchList.setTelNumber(telNumber);
        watchList.setBankName(bankName);
        watchList.setCardType(cardType);
        watchList.setCardNo(cardNo);
        watchList.setStatus(status);
        watchList.setVoucher(voucher);


        return  accountFlowService.updateWatch(watchList,refuse);

    }

}
